MinMaxDay <-function(inpath, outpath, para, fun) {
  
  ##list all files of inpath
  fnames <- list.files(inpath)
  
  ##read in files of fnames
  lapply(1:length(fnames), function(i) {
    df <- read.table(paste(inpath, fnames[i], sep = "/"), header = T, sep = ",", 
              fill = T)
    print(str(df))
    date <- as.character(df[["Datetime"]])
    index <- list(substr(date, 9, 10))
    print(str(index))
    
    output <- aggregate(df[[para]], by = index, FUN = fun, na.rm = T)
    
   # return(output)
    
  })
  write.table(output, outpath, col.names = T, row.names = F, sep = ",")
  
  
  
}